package com.twu.biblioteca;

public class NormalUserInterface implements UserInterface{
    private Console console;

    public NormalUserInterface() {
        this.console = new Console();
    }

    public void displayWelcomeMessage(String libraryName) {
        console.write("Welcome to " + libraryName);
    }

    public void displayMenu(){

        console.write("\n\n\tMenu\n" +
                "  1.List Books\n" +
                "  2.List Movie\n" +
                "  3.Login\n" +
                "  4.Quit\n\n");
    }

    public int getUserChoice() {
        console.write("Enter choice....");
        int input;
        try {
            input = console.readInteger();
        } catch (Exception e) {
            return getUserChoice();
        }
        return input;
    }


    public void processRequest(BibliotecaApp bibliotecaApp, int choice) {
        UserChoice userChoice = UserChoice.values()[choice - 1];
        userChoice.processRequest(bibliotecaApp);
    }

    @Override
    public int quit() {
        return UserChoice.QUIT.getIndex();
    }
}

